<template>
	<view class="banquet-info">
		<view class="c-row-box">
			<view class="c-row-head"><view class="c-row-title">会议</view></view>
			<view class="c-row-item">
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							执行公司
						</view>
						<view class="col-text">
							<picker mode="selector" :range="companyList" range-key="title" @change="companyChange" :disabled="isPreview">
								<view>{{ selectedCompany }}</view>
							</picker>
						</view>
					</view>
				</view>
				
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							举办时间
						</view>
						<view class="col-text">
							<picker mode="date" :disabled="isPreview" :start="parent.startDate" :end="parent.endDate" @change="partyDateChange">
								<view>{{ orderParams.event_date }}</view>
							</picker>
						</view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							签约日期
						</view>
						<view class="col-text">
							<picker mode="date" :disabled="isPreview" :start="parent.startDate" :end="parent.endDate" @change="signDateChange">
								<view>{{ orderParams.sign_date }}</view>
							</picker>
						</view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">公司名称</view>
						<view class="col-text"><input type="text" v-model="meetingParams.customer_company" :disabled="isPreview" placeholder="请输入" /></view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">地址</view>
						<view class="col-text"><input type="text" v-model="meetingParams.address" :disabled="isPreview" placeholder="请输入" /></view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							联系人
						</view>
						<view class="col-text"><input type="text" v-model="orderParams.bridegroom" :disabled="isPreview" placeholder="请输入" /></view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							电话
						</view>
						<view class="col-text">
							<input type="number" maxlength="11" v-model="orderParams.bridegroom_mobile" :disabled="isPreview" placeholder="请输入" />
						</view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							餐饮费用
						</view>
						<view class="col-text">
							<input type="digit" v-model="meetingParams.food_totals" @input="meetingChange" :disabled="isPreview" placeholder="请输入" />
						</view>
					</view>
				</view>
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							布置费用
						</view>
						<view class="col-text">
							<input type="digit" v-model="meetingParams.arrangement" @input="meetingChange" :disabled="isPreview" placeholder="请输入" />
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import dictionary from '@/utils/dictionary.js';

export default {
	props: {
		parent: {
			type: Object,
			default() {
				return {};
			}
		},
		orderParams: {
			type: Object,
			default () {
				return {}
			}
		},
		meetingParams: {
			type: Object,
			default () {
				return {}
			}
		},
		isPreview: {
			type: Boolean,
			default() {
				return false;
			}
		}
	},
	data() {
		return {};
	},
	computed: {
		companyList: function() {
			let companyList = dictionary.getPicker('companyList');
			companyList = companyList.filter(ele => ele.is_valid == 1);
			
			return companyList;
		},
		selectedCompany: function() {
			return dictionary.getPickerTitle('companyList', this.meetingParams.company_id, '请选择');
		},
	},
	beforeMount() {
		this.dictionary = dictionary;
	},
	methods: {
		// 选择公司
		companyChange(e) {
			let index = e.target.value
			this.meetingParams.company_id = this.companyList[index].id
			console.log(this.meetingParams);
			this.$forceUpdate()
		},

		// 派对时间
		partyDateChange(e) {
			this.parent.orderParams.event_date = e.target.value;
		},

		// 签约时间
		signDateChange(e) {
			this.parent.orderParams.sign_date = e.target.value;
		},

		// 信息发生变化
		meetingChange() {
			let food_totals = this.meetingParams.food_totals > 0 ? parseFloat(this.meetingParams.food_totals) : 0;
			let arrangement = this.meetingParams.arrangement > 0 ? parseFloat(this.meetingParams.arrangement) : 0;
			let meeting_totals = (food_totals + arrangement).toFixed(2);
			this.meetingParams.meeting_totals = meeting_totals;
			this.parent.getOrderTotals();
		}
	}
};
</script>

<style lang="less">
@import url('../../components/common.less');
@import url('../common/common.less');
</style>

